package org.example.common.dto;

/**
 * @Author 李荣
 * @Date 2025/1/4
 * @Description
 */
public class ResultUtil {

    public static <T> Result<T> success()
    {
        Result<T> result = new Result<>();
        result.setMsg("");
        result.setData(null);
        result.setCode(0);
        return result;
    }

    public static <T> Result<T> success(T data)
    {
        Result<T> result = new Result<>();
        result.setMsg("");
        result.setData(data);
        result.setCode(0);
        return result;
    }
    public static <T> Result<T> success(T data,String msg)
    {
        Result<T> result = new Result<>();
        result.setMsg(msg);
        result.setData(data);
        result.setCode(0);
        return result;
    }


    public static <T> Result<T> error(String msg,Integer code)
    {
        return new Result<>(null,msg,code);
    }

    public static <T> Result<T> error(ResultEnum resultEnum)
    {
        return new Result<>(null,resultEnum.getMsg(),resultEnum.getCode());
    }

    public static <T> Result<T> error(ResultEnum resultEnum,String msg)
    {
        return new Result<>(null,msg,resultEnum.getCode());
    }
}
